home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_05
/
9n05022c
< prev
next >
Wrap
Text File
|
1991-03-17
|
807b
|
43 lines
#include <stdio.h>
#define NUMELEM(a) (sizeof(a)/sizeof(a[0]))
const char cm0[] = "ADD";
const char cm1[] = "DELETE";
const char cm2[] = "LIST";
const char cm3[] = "REPLACE";
const char *level0[] = {cm2, NULL};
const char *level1[] = {cm0, cm2, cm3, NULL};
const char *level2[] = {cm0, cm1, cm2, cm3, NULL};
const char **mode[] = {level0, level1, level2};
main()
{
int i, j;
for (i = 0; i < NUMELEM(mode); ++i) {
printf("\nLevel %d commands: ", i);
for (j = 0; mode[i][j] != NULL; ++j)
printf(" %s", mode[i][j]);
putchar('\n');
}
}
output:
Level 0 commands: LIST
Level 1 commands: ADD LIST REPLACE
Level 2 commands: ADD DELETE LIST REPLACE
{pasteup: be sure to leave blank lines in between the
lines in the output}